#include<iostream>
#include<cstdio>
#include<cstring>
#include <map>
#include <sstream>
#include<conio.h>
#include<windows.h>
#define M1 Beep(523,200);
#define M2 Beep(587,200);
#define M3 Beep(659,200);
#define M4 Beep(698,200);
#define M5 Beep(784,200);
#define M6 Beep(880,200);
#define M7 Beep(980,200);
#define qdo 262
#define qre 294
#define qmi 330   //q
#define qfa 349
#define qso 392
#define qla 440
#define qsi 494
#define do 523
#define re 578
#define mi 659
#define fa 698
#define so 784
#define la 880
#define si 988
#define do1 1046
#define re1 1175
#define mi1 1318
#define fa1 1480
#define so1 1568
#define la1 1760
#define si1 1976
#define sqdo 277
#define sqre 311
#define sqfa 370
#define sqso 415
#define sqla 466
#define sdo 554
#define sre 622
#define sfa 740
#define sso 831
#define sla 932
#define sdo1 1046
#define sre1 1245
#define sfa1 1480
#define sso1 1661
#define sla1 1865
using namespace std;
void play_piano();
int Judge_function_type(char letter[]) {
    int i1 = 0, i2 = 0;//i1判断括号

    // if(pd_operation(letter))return 4;
    // if(pd_define_vars(letter))return 5;
    if (!std::strcmp(letter,"piano() yr"))play_piano();
    while (letter[i1] != '(')++i1;//找到位置

    if (i1 == std::strlen(letter))return 1;//判断是否有

    else {
        char message[1000];
        for (int i = 0; i <= std::strlen(letter); i++)message[i] = 0;
        for (int j = 0; j < i1; j++) {//将字符串提取
            message[j] = letter[j];
        }
        // std::cout<<message<<std::endl;
        
        if (!std::strcmp(message, "yrsays"))return 2;
        if (!std::strcmp(message, "yreat"))return 3;
        return 1;
    }
    return 0;
}
void play_piano(){
    char ch;int timelen=333; 
	while(1)
	{
		if(kbhit())
		{
			ch=getche();
			switch(ch)
			{
				// case '1':M1;break;
				// case '2':M2;break;
				// case '3':M3;break;
				// case '4':M4;break;
				// case '5':M5;break;
				// case '6':M6;break;
				// case '7':M7;break;
				case '1':Beep(sdo1,timelen);break;
				case '2':Beep(sre1,timelen);break;
				case '3':Beep(sfa1,timelen);break;
				case '4':Beep(sso1,timelen);break;
				case '5':Beep(sla1,timelen);break;
				case '6':Beep(sdo,timelen);break;
				case '7':Beep(sre,timelen);break;
				case '8':Beep(sfa,timelen);break;
				case '9':Beep(sso,timelen);break;
				case '0':Beep(sla,timelen);break;
				case 'q':Beep(do1,timelen);break;
				case 'w':Beep(re1,timelen);break;
				case 'e':Beep(mi1,timelen);break;
				case 'r':Beep(fa1,timelen);break;
				case 't':Beep(so1,timelen);break;
				case 'y':Beep(la1,timelen);break;
				case 'u':Beep(si1,timelen);break;
				case 'i':Beep(sqdo,timelen);break;
				case 'o':Beep(sqre,timelen);break;
				case 'a':Beep(do,timelen);break;
				case 's':Beep(re,timelen);break;
				case 'd':Beep(mi,timelen);break;
				case 'f':Beep(fa,timelen);break;
				case 'g':Beep(so,timelen);break;
				case 'h':Beep(la,timelen);break;
				case 'j':Beep(si,timelen);break;
				case 'k':Beep(sqfa,timelen);break;
				case 'l':Beep(sqso,timelen);break;
				case 'z':Beep(qdo,timelen);break;
				case 'x':Beep(qre,timelen);break;
				case 'c':Beep(qmi,timelen);break;
				case 'v':Beep(qfa,timelen);break;
				case 'b':Beep(qso,timelen);break;
				case 'n':Beep(qla,timelen);break;
				case 'm':Beep(qsi,timelen);break;
				case ',':Beep(sqso,timelen);break;
			}
		}
	}
}
int main(){
    char letter[]="piano() yr";
    Judge_function_type(letter);
    return 0;
}